/*     */ package com.wgcloud.controller;
/*     */ 
/*     */ import com.wgcloud.config.CommonConfig;
/*     */ import com.wgcloud.entity.AccountInfo;
/*     */ import com.wgcloud.util.MD5Utils;
/*     */ import com.wgcloud.util.ThreadPoolUtil;
/*     */ import com.wgcloud.util.staticvar.StaticKeys;
/*     */ import javax.annotation.Resource;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.Model;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/login"})
/*     */ public class LoginCotroller
/*     */ {
/*  31 */   private static final Logger logger = LoggerFactory.getLogger(com.wgcloud.controller.LoginCotroller.class);
/*     */   
/*     */   @Resource
/*     */   private CommonConfig commonConfig;
/*     */   
/*     */   private void testThread() {
/*  37 */     Runnable runnable = () -> logger.info("LoginCotroller----------testThread");
/*     */ 
/*     */     
/*  40 */     ThreadPoolUtil.executor.execute(runnable);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @RequestMapping({"toLogin"})
/*     */   public String toLogin(Model model, HttpServletRequest request) {
/*  53 */     return "login/login";
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @RequestMapping({"loginOut"})
/*     */   public String loginOut(Model model, HttpServletRequest request) {
/*  65 */     HttpSession session = request.getSession();
/*  66 */     session.invalidate();
/*  67 */     return "redirect:/login/toLogin";
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @RequestMapping({"login"})
/*     */   public String login(Model model, HttpServletRequest request) {
/*  79 */     String userName = request.getParameter("userName");
/*  80 */     String passwd = request.getParameter("md5pwd");
/*     */     
/*  82 */     HttpSession session = request.getSession();
/*     */     try {
/*  84 */       if (!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(passwd))
/*     */       {
/*     */ 
/*     */ 
/*     */         
/*  89 */         AccountInfo accountInfo = new AccountInfo();
/*     */         
/*  91 */         if (MD5Utils.GetMD5Code(this.commonConfig.getAccountPwd()).equals(passwd) && this.commonConfig.getAccount().equals(userName)) {
/*  92 */           accountInfo.setAccount(userName);
/*  93 */           accountInfo.setId(userName);
/*  94 */           accountInfo.setRole("admin");
/*  95 */           request.getSession().setAttribute("LOGIN_KEY", accountInfo);
/*  96 */           return "redirect:/dash/main";
/*     */         } 
/*     */ 
/*     */ 
/*     */         
/* 101 */         if (MD5Utils.GetMD5Code(this.commonConfig.getGuestAccountPwd()).equals(passwd) && this.commonConfig.getGuestAccount().equals(userName) && 
/* 102 */           StaticKeys.LICENSE_STATE.equals("1")) {
/* 103 */           accountInfo.setAccount(userName);
/* 104 */           accountInfo.setId(userName);
/* 105 */           accountInfo.setRole("guest");
/* 106 */           request.getSession().setAttribute("LOGIN_KEY", accountInfo);
/* 107 */           return "redirect:/dash/main";
/*     */         }
/*     */       
/*     */       }
/*     */     
/* 112 */     } catch (Exception e) {
/* 113 */       logger.error("登录异常", e);
/*     */     } 
/* 115 */     model.addAttribute("error", "账号或者密码错误");
/* 116 */     return "login/login";
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/controller/LoginCotroller.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */